package cn.oa.dao;

import cn.oa.entity.Department;
import cn.oa.service.DepartmentService;
import cn.oa.service.impl.DepartmentServiceImpl;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.*;

public class DepartmentDaoTest {

    @Test
    public void getAllDepartments() throws SQLException {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-dao.xml");
        DepartmentService departmentService = (DepartmentService) context.getBean("departmentService");
       List<Department> list = departmentService.getAllDepartments();
        for (Department department : list) {
            System.out.println(department);
        }
//        DepartmentService service = (DepartmentService) context.getBean("departmentService");
//        DepartmentServiceImpl a = (DepartmentServiceImpl) service;
//        System.out.println(a.getDepartmentDao()==null);
//        List<Department> list = service.getAllDepartments();
//        for (Department department : list) {
//            System.out.println(department);
//        }
    }
}